/**
* Copyright (c) By zengqh.
*
* This program is just for fun or demo, in the hope that it  
* will be useful, you can redistribute it and/or modify freely.
*
* Time: 2012/12/16
* File: EnnTexture.h
* Blog: http://www.cnblogs.com/zengqh/
**/

#ifndef EnnTexture_h__
#define EnnTexture_h__

#include "EnnPrerequisites.h"

namespace Enn
{
	class GPUObject;
	class Texture : public GPUObject
	{
	public:
		Texture();
		virtual ~Texture();

		/// Set number of requested mip levels. Needs to be called before setting size.
		void SetNumLevels(unsigned levels);

		/// Set filtering mode.
		void SetFilterMode(TextureFilterMode filter);

		/// Set addressing mode by texture coordinate.
		void SetAddressMode(TextureCoordinate coord, TextureAddressMode address);

		/// Return texture format.
		unsigned GetFormat() const { return format_; }

		/// Return whether the texture format is compressed
		bool IsCompressed() const;

		/// Return number of mip levels.
		unsigned GetLevels() const { return levels_; }

		/// Return width.
		int GetWidth() const { return width_; }

		/// Return height.
		int GetHeight() const { return height_; }

		/// Return filtering mode.
		TextureFilterMode GetFilterMode() const { return filterMode_; }

		/// Return addressing mode by texture coordinate.
		TextureAddressMode GetAddressMode(TextureCoordinate coord) const { return addressMode_[coord]; }

		/// Return mip level width, or 0 if level does not exist.
		int GetLevelWidth(unsigned level) const;

		/// Return mip level width, or 0 if level does not exist.
		int GetLevelHeight(unsigned level) const;

		/// Return data size in bytes for a rectangular region.
		unsigned GetDataSize(int width, int height) const;

		/// Return data size in bytes for a pixel or block row.
		unsigned GetRowDataSize(int width) const;


	protected:
		/// Texture format.
		unsigned format_;
		/// Current mip levels.
		unsigned levels_;
		/// Texture width.
		int width_;
		/// Texture height.
		int height_;
		/// Filtering mode.
		TextureFilterMode filterMode_;
		/// Addressing mode.
		TextureAddressMode addressMode_;
	};
}
#endif    /* EnnTexture_h__ */